<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:pe="http://primefaces.org/ui/extensions">


    <ui:define name="content">

        <h:panelGroup >
            <h:form  >
                <p:panel >
                    <f:facet name="header" >
                        <h:panelGrid columns="10"  >
                            <h:outputLabel value="Inward Timed Service" />


                        </h:panelGrid>
                    </f:facet>
                    <p:panel>
                        <h:outputLabel value="From" ></h:outputLabel>
                        <p:calendar id="fd" value="#{inwardTimedItemController.frmDate}" pattern="dd/MMM/yyyy - hh:mm:ss a" ></p:calendar>
                        <h:outputLabel value="From" ></h:outputLabel>
                        <p:calendar id="td" value="#{inwardTimedItemController.toDate}" pattern="dd/MMM/yyyy - hh:mm:ss a" ></p:calendar>
                        <p:autoComplete converter="timedIt" id="it" forceSelection="false" 
                                        value="#{inwardTimedItemController.current.item}"
                                        completeMethod="#{timedItemController.completeInvest}" var="ix" 
                                        itemLabel="#{ix.name}" itemValue="#{ix}" size="30"  style="width: 400px;">
                            <p:column>
                                #{ix.name}
                            </p:column>
                            <p:column>
                                #{ix.total}
                            </p:column>

                        </p:autoComplete>
                        <p:watermark for="it" value="Timed Item"/>


                        <p:commandButton ajax="false" value="Fill" action="#{inwardTimedItemController.createTimeServiceList}" onclick="onSubmitButton();"  />
                        <p:commandButton value="Print" ajax="false" action="#" >
                            <p:printer target="gpBillPreview" ></p:printer>
                        </p:commandButton>

                        <p:commandButton ajax="false" value="Excel" styleClass="noPrintButton" onclick="onSubmitButton();" actionListener="#{inwardTimedItemController.createTimeServiceList}">
                            <pe:exporter type="xlsx" target="tbl" fileName="inward_report_timed_service" />
                        </p:commandButton>
                    </p:panel>
                    <p:panel header="Timed Sevice" id="gpBillPreview">                          
                        <p:dataTable id="tbl" value="#{inwardTimedItemController.items}" var="ti">


                            <f:facet name="header">
                                <h:outputLabel value="#{inwardTimedItemController.current.item.name}"/>
                                <h:outputLabel value=" : "/>
                                <h:outputLabel value="#{inwardTimedItemController.frmDate}">
                                    <f:convertDateTime pattern="dd MMMM yyyy"/>
                                </h:outputLabel>
                                <h:outputLabel value="--"/>
                                <h:outputLabel value="#{inwardTimedItemController.toDate}">
                                    <f:convertDateTime pattern="dd MMMM yyyy"/>
                                </h:outputLabel>
                            </f:facet>


                            <p:column headerText="BHT Number">
                                <f:facet name="header">
                                    <p:outputLabel value="BHT Number"/>
                                </f:facet>
                                <p:outputLabel value="#{ti.patientEncounter.bhtNo}" />
                            </p:column>
                            <p:column headerText="Service Name">
                                <f:facet name="header">
                                    <p:outputLabel value="Service Name"/>
                                </f:facet>
                                <p:outputLabel value="#{ti.item.name}" />
                            </p:column>
                            <p:column headerText="Service Name">
                                <f:facet name="header">
                                    <p:outputLabel value="Service Name"/>
                                </f:facet>
                                <p:outputLabel value="#{ti.bill}" />
                            </p:column>
                            <p:column headerText="Inward Charge Type">
                                <f:facet name="header">
                                    <p:outputLabel value="Inward Charge Type"/>
                                </f:facet>
                                <p:outputLabel value="#{ti.item.inwardChargeType}" />
                            </p:column>
                            <p:column headerText="Start Time">
                                <f:facet name="header">
                                    <p:outputLabel value="Start Time"/>
                                </f:facet>
                                <h:outputLabel value="#{ti.fromTime}"   >
                                    <f:convertDateTime pattern="yy/MM/dd hh:mm:ss a" />
                                </h:outputLabel>
                            </p:column>                               
                            <p:column headerText="Stopped Time">
                                <f:facet name="header">
                                    <p:outputLabel value="Stopped Time"/>
                                </f:facet>
                                <h:outputLabel value="#{ti.toTime}"   >
                                    <f:convertDateTime pattern="yy/MM/dd hh:mm:ss a" />
                                </h:outputLabel>
                            </p:column>
                            <p:column headerText="Time(Minutes)" styleClass="averageNumericColumn">
                                <f:facet name="header">
                                    <p:outputLabel value="Time"/>
                                </f:facet>
                                <h:outputLabel value="#{ti.tmpConsumedTime}" >
                                    <f:convertNumber pattern="##0.0"/>
                                </h:outputLabel>
                            </p:column>
                            <p:column style="text-align: right;" headerText="Discount">
                                <f:facet name="header">
                                    <p:outputLabel value="Discount"/>
                                </f:facet>
                                <h:outputLabel  value="#{ti.discount}">
                                    <f:convertNumber pattern="#,##0.00"/>
                                </h:outputLabel>
                            </p:column>
                            <p:column style="text-align: right;" headerText="Adjusted Value">
                                <f:facet name="header">
                                    <p:outputLabel value="Adjusted Value"/>
                                </f:facet>
                                <h:outputLabel  value="#{ti.adjustedValue}">
                                    <f:convertNumber pattern="#,##0.00"/>
                                </h:outputLabel>
                            </p:column>
                            <p:column style="text-align: right;" headerText="Total">
                                <f:facet name="header">
                                    <p:outputLabel value="Total"/>
                                </f:facet>
                                <h:outputLabel  value="#{ti.serviceValue}">
                                    <f:convertNumber pattern="#,##0.00"/>
                                </h:outputLabel>
                            </p:column>
                            <p:column headerText="Creater">
                                <f:facet name="header">
                                    <p:outputLabel value="Creator"/>
                                </f:facet>

                                <h:outputLabel value="#{ti.creater.webUserPerson.name}"/>     

                                <h:panelGroup rendered="#{ti.retired}" >
                                    <h:outputLabel style="color: red;" value="Deleted By " />

                                    <h:outputLabel style="color: red;"  value="#{ti.retirer.webUserPerson.name}" >                                       
                                    </h:outputLabel>
                                </h:panelGroup>
                            </p:column>  
                            <p:columnGroup type="footer">
                                <p:row>
                                    <p:column footerText="Total" colspan="5">
                                        <f:facet name="footer" >
                                            <p:outputLabel value="Total"></p:outputLabel>
                                        </f:facet>
                                    </p:column>
                                    <p:column footerText="#{inwardTimedItemController.totalMins}" style="text-align: right;" >
                                        <f:facet name="footer" >
                                            <p:outputLabel value="#{inwardTimedItemController.totalMins}"></p:outputLabel>
                                        </f:facet>
                                    </p:column>
                                    <p:column footerText="" colspan="2">
                                        <f:facet name="footer" >
                                            <p:outputLabel value=""></p:outputLabel>
                                        </f:facet>
                                    </p:column>
                                    <p:column style="text-align: right;" footerText="#{inwardTimedItemController.total}">

                                        <f:facet name="footer" >
                                            <h:outputLabel value="#{inwardTimedItemController.total}">
                                                <f:convertNumber pattern="#,#00.00" />
                                            </h:outputLabel>
                                        </f:facet>
                                    </p:column>
                                </p:row>
                            </p:columnGroup>

                        </p:dataTable>
                    </p:panel>



                </p:panel>
            </h:form>

        </h:panelGroup>

    </ui:define>

</ui:composition>
